{assign var="title" value="Users"}
{include file="header.tpl.html"}

<form action="{$smarty.server.REQUEST_URI}" method="post" class="form ajax">

<div class="content">
	
	<div class="toolbar">
		<ul class="buttons">
			<li><a href="#" class="save"><span style="background-image: url(/admin/backend/resources/images/icons/accept.png)">Save</span></a></li>
		</ul>
	</div>
	
	<div class="content-below-toolbar">
		
		<div class="inner-content">
			
			<div class="breadcrumb">
				<a href="../../">Users</a>
				{if $user.id}#{$user.id|str_pad:6:0:$smarty.const.STR_PAD_LEFT}{else}Add user{/if}
			</div>
			
			<div style="float:left; margin-right: 15px">
				
				<p>
					<label for="core_username">Username</label>
					<input type="text" name="core[username]" value="{$user.core.username|escape:"html":"UTF-8"}" id="core_username" />
				</p>
				
				<p>
					<label for="core_email">Email</label>
					<input type="text" name="core[email]" value="{$user.core.email|escape:"html":"UTF-8"}" id="core_email" />
				</p>
				
				<p>
					<label for="core_title">Title</label>
					<select name="core[title]" id="core_title">
						<option value=""></option>
						<option value="Mr" {if $user.core.title=="Mr"}selected="selected"{/if}>Mr</option>
						<option value="Mrs" {if $user.core.title=="Mrs"}selected="selected"{/if}>Mrs</option>
						<option value="Miss" {if $user.core.title=="Miss"}selected="selected"{/if}>Miss</option>
						<option value="Ms." {if $user.core.title=="Ms."}selected="selected"{/if}>Ms.</option>
					</select>
				</p>
				
				<p>
					<label for="core_first_name">First name</label>
					<input type="text" name="core[first_name]" value="{$user.core.first_name|escape:"html":"UTF-8"}" id="core_first_name" />
				</p>
				
				<p>
					<label for="core_last_name">Last name</label>
					<input type="text" name="core[last_name]" value="{$user.core.last_name|escape:"html":"UTF-8"}" id="core_last_name" />
				</p>
				
				<p>
					<label for="core_display_name">Display name</label>
					<input type="text" name="core[display_name]" value="{$user.core.display_name|escape:"html":"UTF-8"}" id="core_display_name" />
				</p>
				
				{foreach from="`$users_custom_schema`" item="column"}
					<p>
						<label for="custom_{$column.Field|strtolower|replace:' ':'_'}">{if $column.meta.label}{$column.meta.label}{else}{$column.Field}{/if}</label>
						{if $column.meta.field_type == 'boolean'}
							<input type="checkbox" name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" value="1" {if $user.custom[$column.Field]}checked="checked"{/if} />
						{elseif $column.Type == 'enum'}
							<select name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}">
								{if !$column.meta.required or !$column.Default}<option></option>{/if}
								{foreach from="`$column.Options`" item="option"}
									<option {if $user.custom[$column.Field] == $option}selected="selected"{/if}>{$option|escape:"html":"UTF-8"}</option>
								{/foreach}
							</select>
						{elseif $column.Type == 'set'}
							{foreach from="`$column.Options`" item="option"}
								<input type="checkbox" name="custom[{$column.Field|escape:"html":"UTF-8"}][]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" value="{$option|escape:"html":"UTF-8"}" {if $option|in_array:$user.custom[$column.Field]}checked="checked"{/if} /> {$option|escape:"html":"UTF-8"}<br />
							{/foreach}
						{elseif $column.Type == 'date'}
							<input type="text" name="custom[{$column.Field|escape:"html":"UTF-8"}]" value="{$user.custom[$column.Field]|escape:"html":"UTF-8"}" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
							<script type="text/javascript" charset="utf-8">
								$(function() {ldelim}
									datePickerController.createDatePicker({ldelim}
										formElements:{ldelim}"custom_{$column.Field|strtolower|replace:' ':'_'}":"Y-ds-m-ds-d"{rdelim}
									{rdelim});
								{rdelim});
							</script>
						{elseif $column.Type == 'text'}
							<textarea name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}">{$user.custom[$column.Field]|escape:"html":"UTF-8"}</textarea>
						{elseif $column.Type == 'tinyblob'}
							<input type="file" maxlength="256" name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
						{elseif $column.Type == 'blob'}
							<input type="file" maxlength="65536" name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
						{elseif $column.Type == 'mediumblob'}
							<input type="file" maxlength="16777216" name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
						{elseif $column.Type == 'longblob'}
							<input type="file" maxlength="4294967296" name="custom[{$column.Field|escape:"html":"UTF-8"}]" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
						{else}
							<input type="text" name="custom[{$column.Field|escape:"html":"UTF-8"}]" value="{$user.custom[$column.Field]|escape:"html":"UTF-8"}" id="custom_{$column.Field|strtolower|replace:' ':'_'}" />
						{/if}
					</p>
				{/foreach}
				
				<p>
					<label for="password1">Password (twice{if $user.id} if changing, blank if not{/if})</label>
					<input type="password" name="password1" value="" id="password1" class="password double" autocomplete="off" /><input type="password" name="password2" value="" id="password2" class="password double" autocomplete="off" />
				</p>
				
			</div>
			
			{if $smarty.session.login.user.user_type==2}
			<div style="float:left">
				
				<p>
					<label for="core_user_type">User type</label>
					<select name="core[user_type]" id="core_user_type" {if $user.id==$smarty.session.login.user.id}disabled="disabled"{/if}>
						<option value="0" {if $user.core.user_type==0}selected="selected"{/if}>Regular</option>
						<option value="1" {if $user.core.user_type==1}selected="selected"{/if}>Administrator</option>
						<option value="2" {if $user.core.user_type==2}selected="selected"{/if}>Superuser</option>
					</select>
				</p>
			
				<div id="access_rights" {if $user.core.user_type!=1}style="display:none"{/if}>
					<label>Access rights</label>
					{foreach from="`$navigation`" key="category" item="links"}
						<h4>{$category|escape:"html":"UTF-8"}</h4>
						{foreach from="`$links`" key="name" item="link"}{if $link != 'seperator'}
							<label for="core_access_rights_{$link.path|replace:'/':'_'}" class="checkbox">
							<input type="checkbox" name="core[access_rights][{$link.path}]" value="1" id="core_access_rights_{$link.path|replace:'/':'_'}" {if $user.core.access_rights[$link.path]}checked="checked"{/if} {if $user.id==$smarty.session.login.user.id}disabled="disabled"{/if} /> {$name|escape:"html":"UTF-8"}<br />
							</label>
						{/if}{/foreach}
					{/foreach}
				</div>
			</div>
			{/if}
			<br class="clear" />
			
		</div>
		
	</div>
	
</div>



</form>


{include file="footer.tpl.html"}